<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/5
 * Time: 13:27
 */
namespace app\admin\model;


use traits\model\SoftDelete;

class Staff extends Base
{
    use SoftDelete;

    protected $autoWriteTimestamp = 'datetime';

    public function setPasswordAttr($value)
    {
        return md5($value);
    }

    public function getStatusAttr($value)
    {
        $status = [0=>'未知',1=>'应用',2=>'禁用'];
        return $status[$value];
    }

    public function getSexAttr($value){
        $status = [0=>'未知',1=>'男',2=>'女'];
        return $status[$value];
    }

    //定义role与node的多对多关联模型
    public function roles()
    {
        return $this->belongsToMany('Role','staff_role');
    }
}